<template>

    <div>
    <!-- Dialog 对话框 -->
    <el-dialog title="会员修改" :visible.sync="info.isshow" @close="close">
      <!-- 中间的内容区--表单 -->
      <el-form
        :model="user"
      
      >
        <!-- 展示 -->
        {{ user }}
        <!-- 1手机号 -->
        <el-form-item label="手机号">
          <el-input v-model="user.phone"></el-input>
        </el-form-item>
        <!-- 2昵称 -->
        <el-form-item label="昵称">
          <el-input v-model="user.nickname"></el-input>
        </el-form-item>
        <!-- 3密码 -->
        <el-form-item label="密码">
          <el-input v-model="user.password" show-password></el-input>
        </el-form-item>
        <!-- 4状态 -->
        <el-form-item label="状态">
          <el-switch
            v-model="user.status"
            :active-value="1"
            :inactive-value="2"
          >
          </el-switch>
        </el-form-item>
      </el-form>
      <!-- 取消和添加 -->
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>

        <el-button type="primary" @click="update">修 改</el-button>
      </div>
    </el-dialog>
  </div>
 
 
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import {formClose} from '../../../mixins';
import { successAlert,errorAlert } from "../../../utils/alert";
import {reqmemberlist, reqmemberinfo, reqmemberedit} from '../../../http/api'

export default {
  props: ['arr','info'],
  mixins:[formClose],
  data() {
    return {
       user: {
        uid: "",
        nickname: "",
        phone: "",
        password: "",
        status: "1",
      },
    };
  },
  computed: {
    ...mapGetters({}),
  },
  mounted() {
    this.getOne()
  },
  methods: {
    ...mapActions({}),
    empty() {
      this.user = {
        uid: "",
        nickname: "",
        phone: "",
        password: "",
        status: "1",
      };
    },
     getOne(uid) {
      //发请求，并且赋值
      reqmemberinfo({ uid: uid }).then((res) => {
        if (res.data.code === 200) {
          //删除randstr
            delete res.data.list.randstr;
          this.user = res.data.list;
          // 清空密码
          this.user.password = "";
        }
      });
    },
     // 6点击修改按钮
    update() {
      // 6.2发送请求reqmemberedit
      reqmemberedit(this.user).then((res) => {
        if (res.data.code == 200) {
          //弹窗成功
          successAlert(res.data.msg);
          //弹窗内容清空
          this.empty();
         //弹窗消失
          this.info.isshow = false;
          //重新请求列表数据
          this.$emit("init");
        }
      });
    },
  },
};
</script>
<style scoped lang="less">
@import "../../../less/index.less";
</style>